package action;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.primefaces.model.chart.PieChartModel;

import dto.InformacionGerencialDTO;
import ejb.AdministrarInformacionGerencialBean;
import java.io.Serializable;

@ManagedBean(name = "informacionGerencialAction")
@SessionScoped
public class InformacionGerencialAction implements Serializable {

    @EJB
    AdministrarInformacionGerencialBean administrarInformacionGerencialBean;

    private PieChartModel informationSource;
    private List<InformacionGerencialDTO> informacionGerencialDTOList;

    @PostConstruct
    public void init() {
        informationSource = new PieChartModel();
        informationSource.setTitle("Informacion gerencial");
        informationSource.setShowDataLabels(true);
        informationSource.setLegendPosition("w");
        //Naranja: FFD55A aguamarina: 62E8FE verde: 90C36D rojo: C24758 purpura: 898AE1 gris:6389AC
        informationSource.setSeriesColors("FFD55A,62E8FE,90C36D,C24758,898AE1,6389AC");

        informacionGerencialDTOList = administrarInformacionGerencialBean.consultarControlesPorMes();

        for (InformacionGerencialDTO info : informacionGerencialDTOList) {
            informationSource.set(info.getFecha(), info.getCantidadCitas());
        }

    }

    public PieChartModel getInformationSource() {
        return informationSource;
    }

    public void setInformationSource(PieChartModel informationSource) {
        this.informationSource = informationSource;
    }

}
